package com.sqf2023.primary;

import java.util.Random;
import java.util.Scanner;

public class arrar
{
    public static void main(String[] args)
    {

        //随机排名
        //定义一个动态初始化的数组用于存储5名员工的工号
        int[] codes = new int[5];

        //录入工号
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < codes.length; i++)
        {
            System.out.println("请输入当前第"+ (i+1) +"个员工的工号");
            int code = sc.nextInt();
            codes[i] = code;
        }

        //3.打乱数组中元素数据
        Random r = new Random();
        for (int i = 0; i < codes.length; i++) {
            int index = r.nextInt(codes.length);
            int temp = codes[index];
            codes[index] = codes[i];
            codes[i] = temp;
        }
        for (int i = 0; i < codes.length; i++) {
            System.out.println(codes[i]);
        }


        //数组反转
        /*
        int[] arr = {10,20,30,40,50};
        int i ,j;
        for(i = 0, j = arr.length-1; i < j; i++, j--)
        {
            int temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
        }
        for(i = 0; i < arr.length; i++)
        {
            System.out.println(arr[i]);
        }
        */
        //数组求最值
        /*
       int[] faceScores = {15,9000,10000,20000,9500,-5};
       int max = faceScores[0];
       int i = 0;
       for(i=0;i<faceScores.length;i++)
       {
           if(faceScores[i]>max)
           {
               max = faceScores[i];
           }
       }
        System.out.println(max);
        */
    }
}
